<?php
include_once "../config/config.php";
include_once "../lib/pdodbmanager.php";
include_once "../lib/functions.php";
include_once "../lib/senitize.php";
$pdo_obj=new PDODBMNanager(HOST,DB,USERNAME,PASS);


//$pdfname="trainer_feedback_report.pdf";
//$pdfname=str_ireplace("_","",$pdfname);
?>
<style type="text/css">
table
{
    width:  100%;
    
    border-collapse: collapse;
    
}
td
{
	padding:5px;
}
</style>
<page>
<br>

<div style="font-size: 22px; font-weight: bold;margin: auto;width:325px;position: relative;border:0px solid"><u>Trainers Feedback Sheet</u><br></div><br><br>

				
				
				<table cellspacing="0" cellpadding="0" style="border-color:#888888" border="1">
					<?php
					//$_POST['query']="select * from users where id in (6)";
					$res_query=$pdo_obj->selectdata($_POST['query']);
					if(count($res_query)>0)
					{
						?>
						<tr style="background:#888888;color:#FFF;border:1px solid #888888">
							<td style="width:10px"><b>Sr No.</b></td>
							<td style="width:100px"><b>Trainer Name</b></td>
							<td style="width:100px"><b>Strongly Agree/Excellent</b></td>
							<td style="width:75px"><b>Agree/Good</b></td>
							<td style="width:100px"><b>Neutral/Average</b></td>
							<td style="width:90px"><b>Disagree/Poor</b></td>
							<td style="width:100px"><b>Strongly Disagree/Very Poor</b></td>
						</tr>
						<?php
							$strongagree=array();
							$agree=array();
							$neutral=array();
							$disagree=array();
							$strongdisagree=array();
							$count=0;
							$str_name="";
							
							for($i=0;$i<count($res_query);$i++)
							{
								$strongagree[$count]=0;
								$agree[$count]=0;
								$neutral[$count]=0;
								$disagree[$count]=0;
								$strongdisagree[$count]=0;
								
								$selecttrainerfeedback="select * from trainer_feedbacks where trainer_id='".$res_query[$i]['id']."'  ";
								$selecttrainerfeedback=$pdo_obj->selectdata($selecttrainerfeedback);
								
								for($k=0;$k<count($selecttrainerfeedback);$k++)
								{
									if(isset($_POST['question_id']) && $_POST['question_id']!="")
										$selecttrnfeedback="select feedback from trn_feedback where trainer_feedbacksid='".$selecttrainerfeedback[$k]['id']."' and feedback_questionid=".$_POST['question_id'];
									else
										$selecttrnfeedback="select feedback from trn_feedback where trainer_feedbacksid='".$selecttrainerfeedback[$k]['id']."'";
									//$selecttrnfeedback="select feedback from trn_feedback where trainer_feedbacksid='".$selecttrainerfeedback[$k]['id']."'  ";
									$selecttrnfeedback=$pdo_obj->selectdata($selecttrnfeedback);
									
									for($j=0;$j<count($selecttrnfeedback);$j++)
									{
										if($selecttrnfeedback[$j]['feedback']=="Strongly Agree" ||$selecttrnfeedback[$j]['feedback']==="Excellent")
										{
											$strongagree[$count]+=1;
										}
										if($selecttrnfeedback[$j]['feedback']==="Agree" || $selecttrnfeedback[$j]['feedback']==="Good")
										{
											$agree[$count]+=1;
										}
										if($selecttrnfeedback[$j]['feedback']==="Neutral" || $selecttrnfeedback[$j]['feedback']==="Average")
										{
											$neutral[$count]+=1;
										}
										if($selecttrnfeedback[$j]['feedback']==="Disagree" || $selecttrnfeedback[$j]['feedback']==="Poor")
										{
											$disagree[$count]+=1;
										}
										if($selecttrnfeedback[$j]['feedback']==="Strongly Disagree" || $selecttrnfeedback[$j]['feedback']==="Very Poor")
										{
											$strongdisagree[$count]+=1;
										}
									}
								}
								
								$count++;
								
								$str_name.="'".trim($res_query[$i]['first_name']." ".$res_query[$i]['last_name'])."',";
								?>
								<tr style="">
									<td style="width:10px;vertical-align:top"><?php echo $count;  ?></td>
									<td style="width:100px;vertical-align:top"><?php echo trim($res_query[$i]['first_name']." ".$res_query[$i]['last_name'])." ( ".$res_query[$i]['code']." )"; ?></td>
									<td style="width:100px;vertical-align:top"><?php echo $strongagree[($count-1)]; ?></td>
									<td style="width:75px;vertical-align:top"><?php echo $agree[($count-1)]; ?></td>
									<td style="width:100px;vertical-align:top"><?php echo $neutral[($count-1)]; ?></td>
									<td style="width:90px;vertical-align:top"><?php echo $disagree[($count-1)]; ?></td>
									<td style="width:100px;vertical-align:top"><?php echo $strongdisagree[($count-1)]; ?></td>
								</tr>
								<?php
							}
					}
					else
					{
					}		
					?>
				</table>

	



</page>
